<html>
<head><meta charset="utf-8"><title>Rust Without Cargo? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html">Rust Without Cargo?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="194356132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194356132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Klein <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194356132">(Apr 16 2020 at 19:34)</a>:</h4>
<p>Are there recommended "best practices" or standards for developing Rust in a Cargo-less environment?</p>
<p>I'm familiar with a handful of projects that enable this -- Bazel's rules_rust/cargo_raze approach, Fuchsia's approach (using GN and avoiding Cargo altogether) but I was kinda curious about these techniques from people more embedded within the rust community</p>



<a name="194356756"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194356756" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Klein <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194356756">(Apr 16 2020 at 19:39)</a>:</h4>
<p>I think I'm particularly interested in environments where multiple programming languages are used together -- which I suppose would be the first motivation for "hey, it's a pain to build my C++/Go/Rust libraries/binaries from Cargo alone"</p>



<a name="194357132"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194357132" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Sean Klein <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194357132">(Apr 16 2020 at 19:42)</a>:</h4>
<p>(also, maybe the answer is "you should still use Cargo in those cases! You should just invoke it by another build system, or whatever!" - just curious to hear what has / hasn't worked well in this space)</p>



<a name="194369941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194369941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194369941">(Apr 16 2020 at 21:29)</a>:</h4>
<p>That's definitely the small-scale recommendation, yes.</p>



<a name="194370011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194370011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194370011">(Apr 16 2020 at 21:30)</a>:</h4>
<p>Doing without Cargo has less to do with mixing languages, and more to do with "we have an existing all-encompassing build system of doom, and everything must fit into that".</p>



<a name="194371119"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194371119" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194371119">(Apr 16 2020 at 21:42)</a>:</h4>
<p>If Rust isn't the primary project language you can set cargo to produce a staticlib and then have the larger build process grab that and make use of it, for example.</p>



<a name="194373293"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194373293" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194373293">(Apr 16 2020 at 22:04)</a>:</h4>
<p>So, I wanted to start a rant about Cargo being an opaque non-divisible non-cooperative blob inside of a dependency graph of any actual build system, including off the shelf CMake, not only "all-encompassing build systems of doom", causing build performance issues once the project size grows.<br>
However, I've just found that Cargo can actually inherit the outer build system's jobserver now, so it's not so uncooperative anymore, just non-divisible and opaque.</p>



<a name="194373790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194373790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194373790">(Apr 16 2020 at 22:09)</a>:</h4>
<p>I personally don't feel like Cargo is that much more indivisible than rustc, or than the use of LTO.</p>



<a name="194373820"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194373820" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194373820">(Apr 16 2020 at 22:09)</a>:</h4>
<p>I don't think it's necessarily a great assumption that all programs should be able to compile like C, where each source file becomes one object, for instance.</p>



<a name="194373845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194373845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194373845">(Apr 16 2020 at 22:09)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> Agreed, that seems like the easiest solution.</p>



<a name="194374426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194374426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194374426">(Apr 16 2020 at 22:15)</a>:</h4>
<p>Hm, AFAIK the "inherit a jobserver" has been true for ... years now? Basically since we started doing it</p>



<a name="194402701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194402701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Vadim Petrochenkov <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194402701">(Apr 17 2020 at 07:23)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116122">simulacrum</span> <a href="#narrow/stream/122651-general/topic/Rust.20Without.20Cargo.3F/near/194374426" title="#narrow/stream/122651-general/topic/Rust.20Without.20Cargo.3F/near/194374426">said</a>:</p>
<blockquote>
<p>Hm, AFAIK the "inherit a jobserver" has been true for ... years now? Basically since we started doing it</p>
</blockquote>
<p>Perhaps the "indivisibility" was resolved as well?<br>
IIRC, if CMake run multiple instances of Cargo in parallel, they started competing with each other for various locks, both global and in the workspace build directory, serializing the build anyway.</p>
<p>(Assume I have a workspace with multiple packages producing staticlibs, cdylibs and executables for consumption by the outer CMake. If each package is made a separate node (target) in CMake build graph, then CMake can build the packages when it's necessary for the larger build, possibly in parallel.)</p>



<a name="194422353"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rust%20Without%20Cargo%3F/near/194422353" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rust.20Without.20Cargo.3F.html#194422353">(Apr 17 2020 at 10:42)</a>:</h4>
<p>No, I think that hasn't been resolved. Cargo still expects to roughly be the only cargo running (and enforces that). Crater currently creates N target directories as a workaround.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>